home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Toolbox
/
Visual Basic Toolbox (P.I.E.)(1996).ISO
/
forms
/
demotod
/
demotped.frm
< prev
next >
Wrap
Text File
|
1995-06-09
|
10KB
|
372 lines
VERSION 2.00
Begin Form DemoTipEdit
BackColor = &H00C0C0C0&
Caption = "Tip of the Day - Editor"
ClientHeight = 3300
ClientLeft = 2895
ClientTop = 2355
ClientWidth = 3435
Height = 3705
Icon = DEMOTPED.FRX:0000
Left = 2835
LinkTopic = "Form1"
ScaleHeight = 3300
ScaleWidth = 3435
Top = 2010
Width = 3555
Begin CommandButton Command_Edit
Caption = "Delete"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 375
Index = 1
Left = 1740
TabIndex = 11
Top = 2460
Width = 1635
End
Begin CommandButton Command_Edit
Caption = "Add"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 375
Index = 0
Left = 60
TabIndex = 10
Top = 2460
Width = 1635
End
Begin CommandButton Command_Navigate
Caption = "Last"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 375
Index = 3
Left = 2580
TabIndex = 9
Top = 2040
Width = 795
End
Begin CommandButton Command_Navigate
Caption = "Next"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 375
Index = 2
Left = 1740
TabIndex = 8
Top = 2040
Width = 795
End
Begin CommandButton Command_Navigate
Caption = "Previous"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 375
Index = 1
Left = 840
TabIndex = 7
Top = 2040
Width = 855
End
Begin CommandButton Command_Navigate
Caption = "First"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 375
Index = 0
Left = 60
TabIndex = 6
Top = 2040
Width = 735
End
Begin CommandButton Command_Exit
Caption = "Exit"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 375
Left = 2340
TabIndex = 5
Top = 2880
Width = 1035
End
Begin CommandButton Command_Save
Caption = "Save Tips"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 375
Left = 1200
TabIndex = 4
Top = 2880
Width = 1035
End
Begin TextBox Text_TipFile
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 285
Left = 60
TabIndex = 2
Text = "\TOD.TIP"
Top = 315
Width = 3315
End
Begin CommandButton Command_Load
Caption = "Load Tips"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 375
Left = 60
TabIndex = 1
Top = 2880
Width = 1035
End
Begin TextBox Text_TOD
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 1305
Left = 60
MultiLine = -1 'True
TabIndex = 0
Top = 645
Width = 3315
End
Begin Label Label1
BackColor = &H00C0C0C0&
Caption = "Location and Name of Tip File"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 195
Left = 60
TabIndex = 3
Top = 75
Width = 2595
End
End
Option Explicit
Dim FileNum
Dim Tips$(500)
Dim TipPos&
Dim TipLen%
Dim NbrTips%
Dim CurrentTip%
Sub Command_Edit_Click (Index As Integer)
Select Case Index
Case 0
If NbrTips% = 500 Then
MsgBox "You have entered the maximum of 500 Tips...", 4, "Sorry"
Else
CurrentTip% = NbrTips%
NbrTips% = NbrTips% + 1
Text_TOD.Text = Tips$(CurrentTip%)
End If
Case 1
If NbrTips% = 1 Then
MsgBox "You cannot delete the last Tip...", 4, "Sorry"
Else
If CurrentTip% = NbrTips% - 1 Then
Tips$(CurrentTip%) = ""
CurrentTip% = CurrentTip% - 1
NbrTips% = NbrTips% - 1
Else
Shift_Tips
End If
Text_TOD.Text = Tips$(CurrentTip%)
End If
End Select
Set_FPNL
End Sub
Sub Command_Exit_Click ()
Unload Me
End Sub
Sub Command_Load_Click ()
FileNum = FreeFile
Open Text_tipFile.Text For Binary As FileNum
TipPos& = 1
NbrTips% = 0
Do
Get FileNum, TipPos&, TipLen%
Tips$(NbrTips%) = Input$(TipLen%, FileNum)
TipPos& = Seek(FileNum)
NbrTips% = NbrTips% + 1
Loop Until TipPos& >= LOF(FileNum)
CurrentTip% = 0
Text_TOD.Text = Tips$(0)
Close FileNum
Set_FPNL
End Sub
Sub Command_Navigate_Click (Index As Integer)
Select Case Index
Case 0
CurrentTip% = 0
Case 1
CurrentTip% = CurrentTip% - 1
Case 2
CurrentTip% = CurrentTip% + 1
Case 3
CurrentTip% = NbrTips% - 1
End Select
Text_TOD.Text = Tips$(CurrentTip%)
Set_FPNL
End Sub
Sub Command_Save_Click ()
Dim i%
On Error Resume Next
Kill Text_tipFile.Text
On Error GoTo 0
FileNum = FreeFile
Open Text_tipFile.Text For Binary As FileNum
TipPos& = 1
TipLen% = Len(Tips$(0))
Put FileNum, TipPos&, TipLen%
Put FileNum, , Tips$(0)
If NbrTips% > 1 Then
For i% = 1 To NbrTips% - 1
TipLen% = Len(Tips$(i%))
Put FileNum, , TipLen%
Put FileNum, , Tips$(i%)
Next i%
End If
Close FileNum
End Sub
Sub Form_Load ()
Text_tipFile.Text = App.Path & Text_tipFile.Text
Command_Load_Click
Set_FPNL
End Sub
Sub Set_FPNL ()
If NbrTips% = 0 Then
Command_Navigate(0).Enabled = False
Command_Navigate(1).Enabled = False
Command_Navigate(2).Enabled = False
Command_Navigate(3).Enabled = False
Exit Sub
Else
Command_Navigate(0).Enabled = True
Command_Navigate(1).Enabled = True
Command_Navigate(2).Enabled = True
Command_Navigate(3).Enabled = True
End If
If CurrentTip% + 2 > NbrTips% Then
Command_Navigate(2).Enabled = False
End If
If CurrentTip% = 0 Then
Command_Navigate(1).Enabled = False
End If
End Sub
Sub Shift_Tips ()
Dim i%
For i% = CurrentTip% + 1 To NbrTips% - 1
Tips$(i% - 1) = Tips$(i%)
Next i%
Tips$(NbrTips% - 1) = ""
NbrTips% = NbrTips% - 1
End Sub
Sub Text_TOD_LostFocus ()
Tips$(CurrentTip%) = Text_TOD.Text
End Sub